home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 50
/
Volume 50 - JOGO DISK .iso
/
Games
/
moonstonemadness.swf
/
scripts
/
__Packages
/
Main.as
< prev
next >
Wrap
Text File
|
2007-09-27
|
12KB
|
319 lines
class Main extends Library.DispatcherBase
{
static var SOUND_VOL_SOUND = 100;
static var SOUND_VOL_MUSIC = 35;
static var SOUND_CAT_SOUND = "SFX";
static var SOUND_CAT_MUSIC = "Music";
static var LOSE_REASON_TIMEOUT = 1;
static var LOSE_REASON_MOONSTONES = 2;
static var LOSE_REASON_QUIT = 3;
static var FRAME_RATE = 36;
static var SECTION_TITLE = "Title";
static var SECTION_INSTRUCTIONS = "Instructions";
static var SECTION_GAME = "Game";
static var SECTION_WIN = "Win";
static var SECTION_LOSE = "Lose";
static var SECTION_HIGHSCORE = "HighScore";
function Main(__mcRef)
{
super();
this.mcRef = __mcRef;
Main.oCtrl = this;
this.oHS = new NickHS();
this.nLatestScore = 0;
this.bHSFromTitle = true;
this.bHSScrolling = false;
this.mcRef.onEnterFrame = Library.Utils.Delegate.create(this,this.doEnterFrame);
Library.Sound.SoundManager.doInit(this.mcRef);
Library.Sound.SoundManager.setCategoryVolume(Main.SOUND_CAT_SOUND,Main.SOUND_VOL_SOUND);
Library.Sound.SoundManager.setCategoryVolume(Main.SOUND_CAT_MUSIC,Main.SOUND_VOL_MUSIC);
this.doStartPackMusic();
this.oTransition = new Library.Transition(this.mcRef.mcTransition);
this.oTransition.__set__Listener(this);
this.doAddListener(this.oTransition);
this.oCodeBox = new CodeBox();
this.doTransitionTo(Main.SECTION_TITLE);
}
static function get Instance()
{
return Main.oCtrl;
}
function get StageRoot()
{
return this.mcRef;
}
function doEnterFrame()
{
super.doEnterFrame();
if(this.bHSScrolling)
{
this.mcRef.mcState.mcHS.txtHSNumber.scroll += this.nHSScrollChange;
this.mcRef.mcState.mcHS.txtHSName.scroll += this.nHSScrollChange;
this.mcRef.mcState.mcHS.txtHSScore.scroll += this.nHSScrollChange;
}
}
function doRollSound()
{
Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Button_Roll.mp3",100,1,true);
}
function doClickSound()
{
Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Button_Click.mp3",100,1,true);
}
function doShowHighScoresFromTitle()
{
this.bHSFromTitle = true;
this.doTransitionTo(Main.SECTION_HIGHSCORE);
}
function onBackToTitle()
{
this.doTransitionTo(Main.SECTION_TITLE);
}
function onPlayerLose(__nLoseReason)
{
this.nLoseReason = __nLoseReason;
this.doTransitionTo(Main.SECTION_LOSE);
}
function onPlayerWin()
{
this.doTransitionTo(Main.SECTION_WIN);
}
function doPlayGame(__bStoryMode)
{
this.bTargetModeStory = __bStoryMode;
this.doTransitionTo(Main.SECTION_GAME);
}
function onTransitionEvent(__nEvent, __oTransition)
{
switch(__nEvent)
{
case Library.Transition.TRANSITION_SCREEN_COVERED:
this.doUnloadSection(this.sCurrentSection);
this.doSetSection(this.sTargetSection);
Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"transition_out.mp3",60);
break;
case Library.Transition.TRANSITION_COMPLETE:
}
}
function doSoundEvent(__nEvent, __oSound)
{
if(__nEvent === Library.Sound.SoundManager.EVENT_SOUND_COMPLETE)
{
if(__oSound == this.oMusicPack)
{
delete this.oMusicPack;
}
}
}
function doSubmitScoreAndRefresh()
{
this.doSubmitScore();
this.bHSFromTitle = false;
var _loc2_ = [0.55059,0.39611,0.0533,0,0,0.20059,0.74611,0.0533,0,0,0.20059,0.39611,0.4033,0,0,0,0,0,1,0];
var _loc3_ = new flash.filters.ColorMatrixFilter(_loc2_);
this.mcRef.mcState.mcButtons.btnSubmitHS.filters = [_loc3_];
this.mcRef.mcState.mcButtons.btnSubmitHS.enabled = false;
}
function doSubmitAndListScore()
{
this.doSubmitScore();
this.bHSFromTitle = false;
this.doTransitionTo(Main.SECTION_HIGHSCORE);
}
function doStartPackMusic()
{
if(this.oMusicPack == undefined)
{
this.oMusicPack = Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_MUSIC,"Packaging.wav",0,999999);
this.oMusicPack.doAddListener(this);
}
this.oMusicPack.doFadeTo(100);
}
function doStopPackMusic()
{
if(this.oMusicPack != undefined)
{
this.oMusicPack.doFadeTo(0);
}
}
function doStopScrollHsList()
{
this.bHSScrolling = false;
}
function doStartScrollHsList(__nChange)
{
this.bHSScrolling = true;
this.nHSScrollChange = __nChange;
}
function doInstructionPageChange(__nChange)
{
this.mcRef.mcState.gotoAndStop(this.mcRef.mcState._currentframe + __nChange);
this.doSetUpInstructions();
}
function get HSM()
{
return this.oHS;
}
function get CodeBoxManager()
{
return this.oCodeBox;
}
function doSubmitScore()
{
this.oHS.bSubmitHS = true;
this.oHS.submitScore(this.nLatestScore);
this.mcRef.mcState.btnSubmitHS._visible = false;
}
function doSetUpTitle()
{
this.mcRef.mcState.btnPlayStory.onRelease = Library.Utils.Delegate.create(this,this.doPlayGame,true);
this.mcRef.mcState.btnPlayUser.onRelease = Library.Utils.Delegate.create(this,this.doPlayGame,false);
this.mcRef.mcState.btnInstructions.onRelease = Library.Utils.Delegate.create(this,this.doTransitionTo,Main.SECTION_INSTRUCTIONS);
this.mcRef.mcState.btnViewHS.onRelease = Library.Utils.Delegate.create(this,this.doShowHighScoresFromTitle);
this.oCodeBox.setBox(this.mcRef.mcState.mcCode);
}
function doSetUpHS()
{
if(this.bHSFromTitle)
{
this.mcRef.mcState.mcButtons.gotoAndStop("Back");
this.mcRef.mcState.mcButtons.btnBack.onRelease = Library.Utils.Delegate.create(this,this.doTransitionTo,Main.SECTION_TITLE);
}
else
{
this.mcRef.mcState.mcButtons.gotoAndStop("PlayAgain");
this.mcRef.mcState.mcButtons.btnPlayAgain.onRelease = Library.Utils.Delegate.create(this,this.doTransitionTo,Main.SECTION_GAME);
}
if(!this.bHSFromTitle)
{
this.mcRef.mcState.txtScore.text = Library.Utils.Tools.getFormatedNumber(this.nLatestScore,9);
}
else
{
this.mcRef.mcState.txtScore._visible = false;
this.mcRef.mcState.mcScoreLabel._visible = false;
}
this.oHS.setHSBoard(this.mcRef.mcState.mcHS);
this.oHS.getScores();
if(this.oHS.bSubmitHS || !this.oHS.getIsLoggedIn() || this.bHSFromTitle)
{
this.mcRef.mcState.mcButtons.btnSubmitHS.useHandCursor = false;
var _loc2_ = [0.55059,0.39611,0.0533,0,0,0.20059,0.74611,0.0533,0,0,0.20059,0.39611,0.4033,0,0,0,0,0,1,0];
var _loc3_ = new flash.filters.ColorMatrixFilter(_loc2_);
this.mcRef.mcState.mcButtons.btnSubmitHS.filters = [_loc3_];
this.mcRef.mcState.mcButtons.btnSubmitHS.enabled = false;
}
else
{
this.mcRef.mcState.mcButtons.btnSubmitHS.onRelease = Library.Utils.Delegate.create(this,this.doSubmitScoreAndRefresh);
}
this.mcRef.mcState.btnHaut.onPress = Library.Utils.Delegate.create(this,this.doStartScrollHsList,-1);
this.mcRef.mcState.btnBas.onPress = Library.Utils.Delegate.create(this,this.doStartScrollHsList,1);
this.mcRef.mcState.btnHaut.onRelease = Library.Utils.Delegate.create(this,this.doStopScrollHsList);
this.mcRef.mcState.btnHaut.onReleaseOutside = Library.Utils.Delegate.create(this,this.doStopScrollHsList);
this.mcRef.mcState.btnHaut.onRollOut = Library.Utils.Delegate.create(this,this.doStopScrollHsList);
this.mcRef.mcState.btnBas.onRelease = Library.Utils.Delegate.create(this,this.doStopScrollHsList);
this.mcRef.mcState.btnBas.onReleaseOutside = Library.Utils.Delegate.create(this,this.doStopScrollHsList);
this.mcRef.mcState.btnBas.onRollOut = Library.Utils.Delegate.create(this,this.doStopScrollHsList);
}
function doSetUpLose()
{
this.doSetUpWinLoseShared();
if(this.nLatestPlayMode == BaseLevelData.LEVEL_TYPE_USER)
{
this.mcRef.mcState.mcScore._visible = false;
}
this.mcRef.mcState.mcReason.gotoAndStop(this.nLoseReason);
}
function doSetUpWin()
{
this.doSetUpWinLoseShared();
}
function doSetUpWinLoseShared()
{
this.bHSFromTitle = false;
if(this.nLatestPlayMode == BaseLevelData.LEVEL_TYPE_STORY)
{
this.mcRef.mcState.btnViewHS.onRelease = Library.Utils.Delegate.create(this,this.doTransitionTo,Main.SECTION_HIGHSCORE);
if(this.oHS.getIsLoggedIn())
{
this.mcRef.mcState.btnSubmitHS.onRelease = Library.Utils.Delegate.create(this,this.doSubmitAndListScore);
}
else
{
this.mcRef.mcState.btnSubmitHS._visible = false;
this.mcRef.mcState.mcCorde1._visible = false;
}
}
else
{
this.mcRef.mcState.btnViewHS._visible = false;
this.mcRef.mcState.btnSubmitHS._visible = false;
this.mcRef.mcState.mcCorde1._visible = false;
this.mcRef.mcState.mcCorde2._visible = false;
this.mcRef.mcState.mcSign._visible = false;
}
this.mcRef.mcState.mcScore.txtScore.text = Library.Utils.Tools.getFormatedNumber(this.nLatestScore,9);
this.mcRef.mcState.btnPlayAgain.onRelease = Library.Utils.Delegate.create(this,this.doTransitionTo,Main.SECTION_GAME);
}
function doSetUpInstructions()
{
this.mcRef.mcState.stop();
this.mcRef.mcState.btnPlay.onRelease = Library.Utils.Delegate.create(this,this.doTransitionTo,Main.SECTION_TITLE);
this.mcRef.mcState.btnNext.onRelease = Library.Utils.Delegate.create(this,this.doInstructionPageChange,1);
this.mcRef.mcState.btnBack.onRelease = Library.Utils.Delegate.create(this,this.doInstructionPageChange,-1);
}
function doCreateGame()
{
this.oGame = new Game(this.mcRef.mcState,this.bTargetModeStory);
}
function doUnloadGame()
{
this.nLatestPlayMode = this.oGame.LevelType;
if(this.nLatestScore > this.oGame.__get__Score())
{
this.oHS.bSubmitHS = false;
}
this.nLatestScore = this.oGame.Score;
this.oGame.doDestroy();
}
function doSetSection(__sSection)
{
this.sCurrentSection = __sSection;
this.mcRef.gotoAndStop(this.sCurrentSection);
switch(this.sCurrentSection)
{
case Main.SECTION_WIN:
this.doSetUpWin();
break;
case Main.SECTION_LOSE:
this.doSetUpLose();
break;
case Main.SECTION_INSTRUCTIONS:
this.doSetUpInstructions();
break;
case Main.SECTION_TITLE:
this.doSetUpTitle();
break;
case Main.SECTION_GAME:
this.doCreateGame();
break;
case Main.SECTION_HIGHSCORE:
this.doSetUpHS();
}
}
function doUnloadSection(__sSection)
{
if(__sSection === Main.SECTION_GAME)
{
this.doUnloadGame();
}
}
function doTransitionTo(__sSection)
{
this.sTargetSection = __sSection;
this.oTransition.doStart();
Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"transition_in.mp3",60);
}
}